package com.xqyq.model;

import java.sql.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

@Entity
@Table(name = "table_match")
public class Match {
	private int match_id;
	// 比赛名字
	private String match_name;
	// 封面
	private String cover;
	// 发布时间
	private Date create_date;
	// 比赛详情
	private MatchContent match_content;
	// 比赛状态（未发布，正在报名，结束报名，比赛结束）
	private int state;
	// 报名
	private List<Sign> signs;
	// 奖项
	private List<Prize> prizes;
	
	private String file_url;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public int getMatch_id() {
		return match_id;
	}

	public void setMatch_id(int match_id) {
		this.match_id = match_id;
	}

	@Column(length = 50, nullable = false)
	public String getMatch_name() {
		return match_name;
	}

	public void setMatch_name(String match_name) {
		this.match_name = match_name;
	}

	public Date getCreate_date() {
		return create_date;
	}

	public void setCreate_date(Date create_date) {
		this.create_date = create_date;
	}

	@OneToOne(cascade = { CascadeType.REFRESH, CascadeType.PERSIST,
			CascadeType.REMOVE }, fetch = FetchType.LAZY, mappedBy = "match")
	public MatchContent getMatch_content() {
		return match_content;
	}

	public void setMatch_content(MatchContent match_content) {
		this.match_content = match_content;
	}

	public int getState() {
		return state;
	}

	public void setState(int state) {
		this.state = state;
	}

	@Lob
	@Column(columnDefinition = "longtext")
	public String getCover() {
		return cover;
	}

	public void setCover(String cover) {
		this.cover = cover;
	}

	@OneToMany(cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY, mappedBy = "match")
	public List<Sign> getSigns() {
		return signs;
	}

	public void setSigns(List<Sign> signs) {
		this.signs = signs;
	}

	@OneToMany(cascade = { CascadeType.REMOVE }, fetch = FetchType.EAGER, mappedBy = "match")
	public List<Prize> getPrizes() {
		return prizes;
	}

	public void setPrizes(List<Prize> prizes) {
		this.prizes = prizes;
	}

	@Override
	public String toString() {
		return "Match [match_id=" + match_id + ", match_name=" + match_name
				+ ", cover=" + cover + ", create_date=" + create_date
				+ ", match_content=" + match_content + ", state=" + state + "]";
	}
	@Column(length = 200)
	public String getFile_url() {
		return file_url;
	}

	public void setFile_url(String file_url) {
		this.file_url = file_url;
	}

}
